from django.db import models
from datetime import datetime

# Create your models here.
# 导航分类模型
class Forks(models.Model):
    objects = models.Manager()
    forkName = models.CharField("分类名称", max_length=100)
    add_time = models.DateTimeField("添加时间", default=datetime.now)

    class Meta:
        db_table = "forks"
        verbose_name = "导航分类"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.forkName


# 文章模型
class Articels(models.Model):
    objects = models.Manager()
    forkby = models.ForeignKey(Forks, related_name="forksby", on_delete=models.CASCADE)
    title = models.CharField("文章标题", max_length=100)
    content = models.CharField("文章内容", max_length=10000)
    add_time = models.DateTimeField("创建时间", default=datetime.now)

    class Meta:
        db_table = "articles"
        verbose_name = "文章"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.title


# 配图模型
class ContentImages(models.Model):
    objects = models.Manager()
    owner = models.ForeignKey(
        Articels, related_name="contentimages", on_delete=models.CASCADE
    )
    iamges = models.ImageField("内容配图", upload_to="contentimages", blank=True, null=True)
    add_time = models.DateTimeField("上传时间", default=datetime.now)

    class Meta:
        db_table = "contentimages"
        verbose_name = "内容配图"
        verbose_name_plural = verbose_name

    # def __str__(self):
    #     return self.owner


class Remarks(models.Model):
    objects = models.Manager()
    title = models.CharField("文章标题", max_length=100)
    content = models.CharField("文章内容", max_length=1000)
    add_time = models.DateTimeField("创建时间", default=datetime.now)

    class Meta:
        db_table = "title"
        verbose_name = "备忘录"
        verbose_name_plural = verbose_name
